package routers

import (
	"gin_cli/conf"
	"gin_cli/controllers"
	"gin_cli/middlerware"
	"gin_cli/routers/api"

	"github.com/gin-gonic/gin"
)

func InitRouter() *gin.Engine {
	r := gin.New()

	r.Use(gin.Logger())

	r.Use(gin.Recovery())
	r.Use(middlerware.Err())
	gin.SetMode(conf.ServerConf.RunMode)
	r.POST("/token", new(controllers.Auth).GetToken)
	r.GET("/log", new(controllers.Log).Get)
	apiv1 := r.Group("/mapi/v1")
	apiv1.Use(middlerware.Auth())

	api.Test(apiv1)
	api.Wechat(apiv1)
	api.Member(apiv1)
	api.Device(apiv1)

	return r
}
